﻿
-- ================================================
-- Remarks: 
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Dasideen_ProjectMemberMaster_Insert') 
    BEGIN
        DROP  PROCEDURE  Dasideen_ProjectMemberMaster_Insert
    END
GO

CREATE PROC [Dasideen_ProjectMemberMaster_Insert]
-- =============================================
-- Author:		<Sagar s.k>
-- Create date: <15/06/2015>
-- Description:	<Dasideen_ProjectMemberMaster_Insert>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				@ProjectMemberUserKey int = NULL,
				@ProjectMemberFirstName varchar(50),
				@ProjectMemberLastName varchar(50) = NULL,
				@ProjectMemberPrimaryEmailID varchar(150),
				@ProjectMemberCodePlexID varchar(50),
				@ProjectMemberSkypeID varchar(50),
				@ProjectMemberMicrosoftID varchar(50) = NULL,
				@ProjectMemberGoogleID varchar(50) = NULL,
				@ProjectMemberTimeZoneReference varchar(50) = NULL,
				@ProjectMemberTimeZoneName varchar(250) = NULL, 
				@ProjectMemberTimeZoneAbbreviation varchar(50) = NULL,
				@ProjectMemberCountryName varchar(150) = NULL,
				@ProjectMemberCityName varchar(150) = NULL,
				@ProjectMemberDateOfJoining datetime = NULL,
				@ProjectMemberIsMemberOfFacebook bit = NULL,
 
				@Sys_CreatedByID varchar(50)= NULL,
				@Sys_ModifiedByID varchar(50) = NULL,
				@Sys_DeleteType int = 0,
				@Sys_OrganizationID int = NULL,
				@Sys_InitialPrimaryKeys varchar(max)= NULL,
				@Sys_WorkstationName varchar(50)= NULL,
				
				@Sys_DateOfCreation datetime OUTPUT,
				@ProjectMemberKey int OUTPUT
				
	)
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
    SET NOCOUNT OFF 
	
	IF @Sys_WorkstationName = 'Default'	
	BEGIN
		SET @Sys_WorkstationName = (SELECT @@SERVERNAME);
	END
	DECLARE @CurrentDataTime datetime;
	SET @CurrentDataTime = GETDATE();

    INSERT INTO [ProjectMemberMaster]
            ( 
				[ProjectMemberUserKey] ,
				[ProjectMemberFirstName] ,
				[ProjectMemberLastName],
				[ProjectMemberPrimaryEmailID] ,
				[ProjectMemberCodePlexID] ,
				[ProjectMemberSkypeID] ,
				[ProjectMemberMicrosoftID] ,
				[ProjectMemberGoogleID] ,
				[ProjectMemberTimeZoneReference] ,
				[ProjectMemberTimeZoneName] ,
				[ProjectMemberTimeZoneAbbreviation] ,
				[ProjectMemberCountryName] ,
			    [ProjectMemberCityName] ,
				[ProjectMemberDateOfJoining] ,
				[ProjectMemberIsMemberOfFacebook] ,


				[Sys_DateOfCreation] ,
				[Sys_DateOfModification] ,
				[Sys_CreatedByID] ,
				[Sys_ModifiedByID] ,
				[Sys_DeleteType] ,
				[Sys_IsDeleted] ,
				[Sys_OrganizationID] ,
				[Sys_InitialPrimaryKeys] ,
				[Sys_WorkstationName]
            )
	VALUES
			(  
				@ProjectMemberUserKey ,
                @ProjectMemberFirstName ,
				@ProjectMemberLastName ,
                @ProjectMemberPrimaryEmailID ,
				@ProjectMemberCodePlexID ,
				@ProjectMemberSkypeID ,
				@ProjectMemberMicrosoftID ,
				@ProjectMemberGoogleID ,
				@ProjectMemberTimeZoneReference ,
				@ProjectMemberTimeZoneName ,
				@ProjectMemberTimeZoneAbbreviation ,
				@ProjectMemberCountryName ,
				@ProjectMemberCityName ,
				@ProjectMemberDateOfJoining ,
				@ProjectMemberIsMemberOfFacebook ,

                @CurrentDataTime ,
                @CurrentDataTime ,
                @Sys_CreatedByID ,
                @Sys_ModifiedByID ,
                @Sys_DeleteType ,
                0,
                @Sys_OrganizationID ,
                @Sys_InitialPrimaryKeys ,
                @Sys_WorkstationName
			);
    SET @ProjectMemberKey = SCOPE_IDENTITY();
	SET @Sys_DateOfCreation = @CurrentDataTime;
END
GO